import 'package:bxultimate/app/router/router_name.dart';
import 'package:bxultimate/app/router/router_page.dart';
import 'package:bxultimate/app/theme/app_theme.dart';
import 'package:bxultimate/initializer/app_initializer.dart';
import 'package:bxultimate/shared/shared.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';

Future<void> main() async {
  await AppInitializer.init();
  late bool? isFirstOpen =
      UtilSp.getBool(AppConstant.isFirstOpen, defValue: true);
  runApp(MyApp(isFirstOpen: isFirstOpen));
}

class MyApp extends StatelessWidget {
  MyApp({super.key, required this.isFirstOpen});

  final bool? isFirstOpen;

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: '兵馨',
      locale: const Locale('zh', 'CN'),
      // showPerformanceOverlay: true, //显示性能标签
      // 去除右上角debug的标签
      debugShowCheckedModeBanner: false,
      // checkerboardRasterCacheImages: true,
      // showSemanticsDebugger: true, // 显示语义视图
      // checkerboardOffscreenLayers: true, // 检查离屏渲染
      theme: AppTheme.getCurrentTheme(),
      // 首页路由初始化
      initialRoute: isFirstOpen! ? RouterName.splash : RouterName.main,
      getPages: RouterPage.routes,
      navigatorObservers: [FlutterSmartDialog.observer],
      builder: FlutterSmartDialog.init(),
    );
  }
}
